import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName, baseUrl } from '@/config'

export async function login(data) {
  // if (loginRSA) {
  //   data = await encryptedData(data)
  // }
  return request({
    // url: `${baseUrl}/account/login/`,
    url: `/login`,
    method: 'post',
    data,
  })
}

export function getUserInfo(accessToken) {
  return request({
    headers: {
      accessToken: accessToken,
    },
    // url: `${baseUrl}/account/userInfo/`,
    url: '/userInfo',
    method: 'post',
    // data: {
    //   [tokenName]: accessToken,
    // },
  })
}

export function resetPassword(data) {
  return request({
    url: `${baseUrl}/account/password-reset/`,
    method: 'post',
    data,
  })
}

export function logout(token) {
  return request({
    url: '/logout',
    method: 'post',
  })
}

export function register(data) {
  return request({
    url: `${baseUrl}/account/register/`,
    method: 'post',
    data,
  })
}
